package com.software.graduationproject.modules.food.service;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.Page;

import com.software.graduationproject.commons.select.Select;
import com.software.graduationproject.modules.food.entity.FoodType;
import com.software.graduationproject.modules.food.mapper.FoodTypeMapper;
import com.software.graduationproject.modules.food.object.FoodTypeVo;
import com.software.graduationproject.modules.food.object.FoodTypeCreateQo;
import com.software.graduationproject.modules.food.object.FoodTypeUpdateQo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
 * FoodTypeService : 食品表
 * ---------------------------------------------------------------------------------------------------------------------
 */
@Service
public class FoodTypeService {

    @Autowired
    private FoodTypeMapper foodTypeMapper;

    public void createQo(FoodTypeCreateQo qo){
        FoodType foodType = new FoodType();
        BeanUtil.copyProperties(qo, foodType);
        foodTypeMapper.insert(foodType);
    }
//
//    public void updateQo(FoodTypeUpdateQo qo){
//        FoodType foodType = foodTypeMapper.select(qo.getId());
//        if (foodType == null){
//            throw  new ServiceException("数据不存在");
//        }
//
//        Beans.copyPropertiesNotNull(foodType, qo);
//        foodTypeMapper.update(foodType);
//    }
//
//    public FoodTypeVo selectVo(Long id) {
//        FoodTypeVo foodTypeVo = new FoodTypeVo();
//        FoodType foodType = foodTypeMapper.select(id);
//        Beans.copyPropertiesNotNull(foodTypeVo, foodType);
//        return foodTypeVo;
//    }

    public Page<FoodTypeVo> selectPageVo(Select select){
        return foodTypeMapper.selectPageVo(select);
    }

    public List<FoodTypeVo> selectListVo(Select select){
        return foodTypeMapper.selectListVo(select);
    }
}
